import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const home = () => import( /*webpackChunkName:'home'*/ 'views/home')
const category = () => import( /*webpackChunkName:'category'*/ 'views/category')
const cart = () => import( /*webpackChunkName:'cart'*/ 'views/cart')
const profile = () => import( /*webpackChunkName:'profile'*/ 'views/profile')
const detail = () => import( /*webpackChunkName:'detail'*/ 'views/detail')

const routes = [{
  path: '/',
  redirect: '/home'
}, {
  path: '/home',
  component: home
}, {
  path: '/category',
  component: category
}, {
  path: '/cart',
  component: cart
}, {
  path: '/profile',
  component: profile
}, {
  path: '/detail/:iid', // 动态匹配路由
  component: detail
  /**query 匹配路由 ： path:'/detail'
   *  通过 this.$router.push({
   *  path:'/detaol',
   *  query:{
   *    iid:iid
   *  } 进行跳转
   * })
   **/
}]

const router = new VueRouter({
  mode: 'history',
  routes
})

export default router